<template>
  <div :class="navBarFixed == true ?  'ani-header' : 'ani-headered'">
    <div class="header">
      <div class="header-left">
        <router-link to="/">
          <div class="iconfont back-icon">&#xe607;</div>
        </router-link>
      </div>
      <div class="header-title">
        <div class="header-title-prefix">旅游度假</div>
        <i class="dot">.</i>
        <router-link to="/vacationcity">
          <span class="header-title-text">
            <span>{{this.currentCity}}</span>
            <span>站</span>
            <span class="iconfont arrow-icon">&#xe606;</span>
          </span>
        </router-link>
      </div>
    </div>

    <div class="search">
      <div class="search-container" style="margin-right: 0rem; transform: translate(0rem, .12rem);">
        <router-link to="/vacation/search">
          <div class="m-search m-search-header">
            <div class="ipt">
              <div class="iconfont icon-search">&#xe605;</div>
              <div class="inp-text">搜索目的地享首单立减</div>
            </div>
          </div>
        </router-link>
      </div>
    </div>
  </div>
</template>

<script>
import { mapState, mapMutations } from "vuex";
export default {
  name: "VacationHeader",
  data() {
    return {
      navBarFixed: true
    };
  },
  methods: {
    watchScroll() {
      var scrollTop =
        window.pageYOffset ||
        document.documentElement.scrollTop ||
        document.body.scrollTop;
      if (scrollTop > 100) {
        this.navBarFixed = true;
      } else {
        this.navBarFixed = false;
      }
    }
  },
  mounted() {
    window.addEventListener("scroll", this.watchScroll);
  },
  computed: {
    ...mapState({
      currentCity: "city"
    })
  }
};
</script>
<style lang="stylus" scoped>
@import '~styles/varibles.styl';

.ani-header {
  position: fixed;
  top: 0;
  width: 100%;
  height: 2rem;
  background: #fff;
  z-index: 999;
}

.ani-headered {
  width: 100%;
  height: 2rem;
  background: #fff;
  z-index: 999;
}

.header {
  display: flex;
  height: $headerHeader;
  line-height: $headerHeader;
  color: #fff;
}

.header-left {
  width: 0.64rem;
  float: left;
}

.back-icon {
  text-align: center;
  font-size: 0.4rem;
  color: #000;
}

.header-title {
  flex: 2;
  margin: 0 1.2rem;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-weight: 400;
}

.header-title-prefix {
  display: inline-block;
  vertical-align: middle;
  color: #616161;
  font-weight: 300;
  font-size: 0.32rem;
}

.arrow-icon {
  font-size: 0.24rem;
  color: #000;
}

.dot {
  display: inline-block;
  vertical-align: middle;
  margin: 0 0.08rem;
  width: 0.08rem;
  height: 0.08rem;
  background: #616161;
  border-radius: 50%;
}

.header-title-text {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  position: relative;
  display: inline-block;
  vertical-align: middle;
  font-size: 0.32rem;
  line-height: 0.44rem;
  color: #212121;
  max-width: 1.5rem;
  font-weight: 400;
}

.search {
  position: absolute;
  top: 0.88rem;
  width: 100%;
  z-index: 999;
  padding: 0.1rem 0.6rem 0.24rem;
}

.m-search {
  display: flex;
  width: 6rem;
  -webkit-box-align: center;
  align-items: center;
  height: 0.6rem;
  line-height: 0.6rem;
  border-radius: 0.6rem;
  background-clip: padding-box !important;
  color: #333;
  border: 0.02rem solid #9e9e9e;
  margin: 0;
}

.ipt {
  display: flex;
  align-items: center;
  -webkit-box-pack: center;
  justify-content: center;
  font-size: 0.26rem;
  line-height: 1.5;
}

.icon-search {
  display: block;
  margin-left: 0.12rem;
  margin-right: 0.12rem;
  color: #ccc;
  text-align: center;
  background-position: -1.5rem -1rem;
}

.inp-text {
  display: block;
  flex: 1;
  width: 100%;
  height: auto;
  padding-right: 0.06rem;
  text-indent: 0.06rem;
  border-top-right-radius: 0.6rem;
  border-bottom-right-radius: 0.6rem;
  color: #ccc;
}
</style>